﻿/*
 * @author: wizardc
 */

using Newtonsoft.Json;

namespace Dou.Utils
{
    /// <summary>
    /// JSON 工具类
    /// </summary>
    public static class JsonUtil
    {
        /// <summary>
        /// 编码
        /// </summary>
        public static string Encode(object obj)
        {
            return JsonConvert.SerializeObject(obj);
        }
        
        /// <summary>
        /// 解码
        /// </summary>
        public static object Decode(string str)
        {
            return JsonConvert.DeserializeObject(str);
        }
        
        /// <summary>
        /// 解码
        /// </summary>
        public static object Decode<T>(string str)
        {
            return JsonConvert.DeserializeObject<T>(str);
        }
    }
}
